import axios from 'axios'
import store from '../store'
// 请求拦截 设置统一 的请求头
axios.interceptors.request.use(config => {
    store.dispatch('setLoading', true)
    if (localStorage.jwt) {
        config.headers.Authorization = localStorage.jwt
    }
    return config
})

// 响应拦截 设置统一 的请求头
axios.interceptors.response.use(response => {
    store.dispatch('setLoading', false)

    return response
})

export default axios
